const handleChartData = (headerData, data) => {
  let legendData = []
  let xAxisData = []
  let seriesData = []
  for (let i = 0; i < headerData.length; i++) {
    // 初始化柱图数据
    if (headerData[i].name === 'sevenDayUserAlive' || headerData[i].name === 'monthUserAlive') {
      legendData.push(headerData[i].label)
      let obj = {
        name: headerData[i].label,
        type: 'line',
        smooth: true,
        itemStyle: {normal: {areaStyle: {type: 'default'}}},
        data: []
      }
      for (let j = 0; j < data.length; j++) {
        let name = headerData[i].name
        obj.data.push(data[j][name])
      }
      seriesData.push(obj)
    }
  }
  for (let i = 0; i < data.length; i++) {
    xAxisData.push(data[i].checkDate)
  }
  return {legendData, xAxisData, seriesData}
}

export default handleChartData
